<?php
/**
 * Description: 获取课程过滤器考试地区列表
 * User: devforma
 * Date: 15/6/6
 * Time: 12:50
 */
class CourseFilterArea implements iController {
    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {

        $areas = $this->getAreaCodeRelation(); //获取课程过滤地区列表

        $list = array();
        foreach ($areas as $code => $name) {
            $list[] = array(
                'code' => $code,
                'name' => $name
            );
        }

        return genOutput(1, array(
            'list' => $list
        ));
    }

    /**
     * 获取考试地区列表
     * @return mixed
     */
    private function getAreaCodeRelation() {

        $cacheKey = 'func:getAreaCodeRelation';

        if (($areas = cacheGet($cacheKey)) == null) {
            $areas = include CONFIG_DIR . '/courseArea.config.php';

            cacheAdd($cacheKey, $areas, 24*3600);
        }

        return $areas;
    }
}